package com.chenshu.transaction.service;

import com.chenshu.transaction.mapper.LogMapper;
import com.chenshu.transaction.model.LogInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

/**
 * Created with IntelliJ IDEA
 * Description
 * User：chenshu
 * Date：2024-04-27
 * Time：14:35
 */
@Service
public class LogService {
    @Autowired
    private LogMapper logMapper;
    @Transactional(propagation = Propagation.NESTED)
    public Integer insertLog(LogInfo logInfo) {
        Integer ret = logMapper.insertLog(logInfo);
        try {
            int a = 10/0;
        } catch (Exception e) {
            throw e;
            //TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }
        return  ret;
    }
}
